<template>
    <!-- 
    <b-modal ref="my-modal" hide-footer title="Using Component Methods">
     <div class="d-block text-center">
       <h3>Hello From My Modal!</h3>
     </div>
     <b-button class="mt-3" variant="outline-danger" block @click="hideModal">Close Me</b-button>
     <b-button class="mt-2" variant="outline-warning" block @click="toggleModal">Toggle Me</b-button>
   </b-modal> 
    -->
    <!--
        body-class="modalStyle" 表示样式
        size="lg" 表示模态窗口大小 xl,lg,sm,full
        hide-footer 表示隐藏底部按钮
        hide-header 表示隐藏头部内容
        no-close-on-backdrop 表示鼠标点击背景不可关闭
        hide-header-close 表示隐藏头部关闭按钮
        centered 居中
        ok-title=“确定” 
        cancel-title=取消
        @ok="handleOk" 
        @cancel="handleCancel"
        scrollable 滚动条
        hide-backdrop 隐藏背景
        wrapClassName="ant-modal-cust-warp" 
        style="top:5%;height: 85%;overflow-y: hidden" 样式
    -->
    <b-modal ref="my-modal" size="xl" title="Redis配置详情" hide-footer scrollable no-close-on-backdrop>
        <div class="d-block text-center">
            <!--begin::div-->
            <div class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed">
                <div class="m-portlet__body">
                    <div class="form-group m-form__group row">
                        <label class="col-lg-2 col-form-label">名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称</label>
                        <div class="col-lg-3">
                            <input class="form-control" type="text" disabled maxlength="100" v-model="ompRedisConfigForm.name" placeholder="请输入">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-lg-2 col-form-label">ip</label>
                        <div class="col-lg-3">
                            <input class="form-control" type="text" disabled maxlength="20" v-model="ompRedisConfigForm.host" placeholder="请输入">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-lg-2 col-form-label">端&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;口</label>
                        <div class="col-lg-1">
                            <el-input-number 
                            v-model="ompRedisConfigForm.port" 
                            maxlength="10" 
                            disabled
                            style="width:100px;" 
                            controls-position="right"
                             :min="0" 
                             :max="10">
                            </el-input-number>
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-lg-2 col-form-label">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码</label>
                        <div class="col-lg-3">
                            <input class="form-control" disabled v-model="ompRedisConfigForm.password" placeholder="请输入">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-lg-2 col-form-label">最大连接数</label>
                        <div class="col-lg-1">
                            <el-input-number 
                            v-model="ompRedisConfigForm.max_total" 
                            maxlength="10" 
                            style="width:100px;" 
                            controls-position="right"
                            disabled
                             :min="0" 
                             :max="10">
                            </el-input-number>
                        </div>
                        <label class="col-lg-3 col-form-label">
                            <b-badge class="mr-1" variant="info">可用连接实例的最大数目，默认值为8；</b-badge>  
                        </label>
                    </div>

                    <div class="form-group m-form__group row">
                        <label class="col-lg-2 col-form-label">最大空闲数</label>
                        <div class="col-lg-1">
                            <input class="form-control" disabled v-model="ompRedisConfigForm.max_idle" placeholder="请输入">
                        </div>
                        <label class="col-lg-3 col-form-label">
                            <b-badge class="mr-1" variant="danger">控制一个pool最多有多少个状态为idle(空闲的)的jedis实例，默认值也是8。</b-badge>  
                        </label>
                    </div>

                    <div class="form-group m-form__group row">
                        <label class="col-lg-2 col-form-label">最大等待时间</label>
                        <div class="col-lg-1">
                            <el-input-number 
                            v-model="ompRedisConfigForm.max_wait_millis" 
                            maxlength="10" 
                            style="width:100px;"
                            disabled 
                            controls-position="right"
                             :min="0" 
                             :max="10">
                            </el-input-number>
                        </div>
                        <label class="col-lg-7 col-form-label">
                            <b-badge class="mr-1" variant="warning">等待可用连接的最大时间，单位毫秒，默认值为-1，表示永不超时。如果超过等待时间，则直接抛出。</b-badge>  
                        </label>
                    </div>

                    <div class="form-group m-form__group row">
                        <label class="col-lg-2 col-form-label">超时时间</label>
                        <div class="col-lg-1">
                            <el-input-number 
                            v-model="ompRedisConfigForm.timeout" 
                            maxlength="10" 
                            disabled
                            style="width:100px;" 
                            controls-position="right"
                             :min="0" 
                             :max="10">
                            </el-input-number>
                        </div>
                    </div>

                    <div class="form-group m-form__group row">
                        <label class="col-lg-2 col-form-label">校&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验</label>
                        <div class="col-lg-1">
                            <select class="form-control" disabled v-model="ompRedisConfigForm.test_on_borrow" title="在从池中取出连接前是否进行检验,如果检验失败,则从池中去除连接并尝试取出另一个。true为检查，false为不检查。设置为true时，当连接池中的连接全部被占后，导致后续操作，获取不到数据，这些程序会等待，直到超时或者获取到有效连接为主">
                                <option value="true">是</option>
                                <option value="false">否</option>
                            </select>
                        </div>
                        <label class="col-lg-7 col-form-label">
                            <b-badge class="mr-1" variant="dark">在从池中取出连接前是否进行检验,如果检验失败,则从池中去除连接并尝试取出另一个。true为检查，false为不检查。</b-badge>  
                        </label>
                    </div>

                    <div class="form-group m-form__group row">
                        <label class="col-lg-2 col-form-label">排序编号</label>
                        <div class="col-lg-1">
                            <el-input-number 
                            disabled
                            v-model="ompRedisConfigForm.sort" 
                            maxlength="10" 
                            style="width:100px;" 
                            controls-position="right"
                             :min="0" 
                             :max="10">
                            </el-input-number>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <template slot="modal-footer">
            <!--自定义按钮-->
        </template>
    </b-modal>
</template>
<script>
import apiUtil from "@/core/util/apiUtil.js";
import { handleNotify, handleAlert, handleConfirm, showWating, closeWating } from "@/core/util/jehcUtil.js";
export default {
    data() {
        return {
            ompRedisConfigForm: {
                name: "",
                host:"",
                port:"6379",
                password:"",
                max_total:"8",
                max_idle:"8",
                max_wait_millis: "-1",
                timeout: "10000",
                test_on_borrow: true,
                sort: "",

            }
        }
    },
    components: {

    },
    watch: {
    },
    mounted() {

    },
    methods: {
        showModal(id) {
            this.restForm();
            this.$refs['my-modal'].show();
            this.getDetail(id);
        },
        hideModal() {
            this.$refs['my-modal'].hide()
        },
        toggleModal() {
            // 当模态已隐藏时，我们传递要返回焦点的按钮的ID
            this.$refs['my-modal'].toggle('#toggle-btn')
        },
        restForm() {
            //重置
            Object.assign(this.$data.ompRedisConfigForm, this.$options.data().ompRedisConfigForm);
        },
        getDetail(id){
            apiUtil.get(process.env.VUE_APP_OMP_API+"/omp/redisConfig/get/"+id).then(({ data }) => {
                this.ompRedisConfigForm = data.data;
            });
        },
    }
}
</script>